// .........................................................................
// Title: macro_series.do
//
// Imports macro series used in the analysis
// .........................................................................

* -------------------------------------------
* Import macro series
* -------------------------------------------

* Import GZ index
import delimited using "$raw/gz_credit_spread/ebp_csv.csv", clear
gen date_m = mofd(date(date, "MY"))
format %tm date_m
drop date
order date_m
save "$tmp/gz_index", replace

* GZ index lags
use "$tmp/gz_index", clear
tsset date_m
gen l_gz_spread = L.gz_spread
forval i = 2/12 {
    gen l`i'_gz_spread = L`i'.gz_spread
}
save "$tmp/gz_lags", replace

* GZ index with deltas
use "$tmp/gz_index", clear
tsset date_m
gen gz_pct_delta = (gz_spread - L.gz_spread) / L.gz_spread
keep date_m gz_spread gz_pct_delta
save "$tmp/gz_m", replace
